package com.cmcc.pcap.packet.udp;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.pcap4j.packet.IpPacket;
import org.pcap4j.packet.UdpPacket;

import java.sql.Timestamp;

/**
 * 
 * @author Amish
 * @date 2018年12月24日 下午3:49:08
 *
 */
public class UdpProducer implements Runnable {
	public static Logger logger = LogManager.getLogger(UdpProducer.class);
	UdpConnectionCache udpConnectionCache;
	IpPacket ipPacket;
	Timestamp timestamp;
	
	public UdpProducer(IpPacket ipPacket , UdpConnectionCache udpConnectionCache, Timestamp timestamp){
		this.udpConnectionCache = udpConnectionCache;
		this.ipPacket = ipPacket;
		this.timestamp = timestamp;
	}

	@Override
	public void run() {
		UdpPacketDecorator udpPacketDecorator = new UdpPacketDecorator();
		udpPacketDecorator.ipPacket = ipPacket;
		udpPacketDecorator.udpPacket = ipPacket.get(UdpPacket.class);
		udpPacketDecorator.timestamp = this.timestamp;
		this.udpConnectionCache.addUDPPacketDecorator(udpPacketDecorator);
	}
}